/*
	YoghurtGum - 2D Game Engine

	Copyright 2009-2011 Quinten Lansu
	
	Licensed under the Apache License, Version 2.0 (the "License"); you may not 
	use this file except in compliance with the License. You may obtain a copy 
	of the License at 
		
		http://www.apache.org/licenses/LICENSE-2.0 
		
	Unless required by applicable law or agreed to in writing, software 
	distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
	WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 
	License for the specific language governing permissions and limitations 
	under the License. 
*/

#ifndef _SETTINGS_H_
#define _SETTINGS_H_

#include "YGPlatform.h"

#define YG_MAJOR_VERSION        0
#define YG_MINOR_VERSION        3
#define YG_BUG_VERSION          0

#define YG_CLASS                L"YoghurtGum"
#define YG_TITLE                L"YoghurtGum 0.3.0"

/*
	Output errors, warnings and relevant information to the console.
*/

#define YG_CONSOLE

/*
	Output errors, warnings and relevant information to a .log file.
*/

#define YG_LOG

#ifdef YG_LOG

	/*
		How many characters a single line can hold before being forced to output to the console / a file.	
	*/

	#ifndef YG_LOG_SIZE
		#define YG_LOG_SIZE			1024
	#endif

	/*
		If we're in the emulator, we might want to output the Log to a file on the harddisk as well.
		Turn this setting off when testing or deploying your game on a device instead of the emulator.
	*/

	#define YG_LOG_EMULATOR

	/*
		Output the average frames per second over 100 frames to the log.
	*/

	//#define YG_LOG_FPS

#endif

/*
	When HARDWARE or SOFTWARE is commented out, it forces the engine to use either.
	This allows for tighter, smaller code, but doesn't always work.
	For instance, forcing the engine to use hardware rendering when the device doesn't support it results in a crash.
	The standard setting is both HARDWARE and SOFTWARE enabled, where the engine determines which mode to use.
*/

#define YG_RENDER_HARDWARE
#define YG_RENDER_SOFTWARE

/*
	Use a backbuffer. This avoids an effect called shearing, where half of the previous frame is still visible while
	the new frame is rendered. However, it results in a lower FPS.
*/

#ifndef YG_USE_BACKBUFFER
	#define YG_USE_BACKBUFFER
#endif

/*
	Use a fixed timestep. You'll probably want this.
*/

//#define YG_USE_FIXED_TIMESTEP
#define YG_FIXED_TIMESTEP       (float)(1000.f / 60.f)

#if (YG_OS_TYPE == YG_OS_TYPE_ANDROID)

	#define YG_MAX_PATH         260

#elif (YG_OS_TYPE == YG_OS_TYPE_WINDOWSMOBILE)

	#include <stdio.h>
	#define YG_MAX_PATH         _MAX_PATH

#elif (YG_OS_TYPE == YG_OS_TYPE_BADA)

	#define YG_MAX_PATH         260

#endif

// =========================================
// Running mode
// =========================================

#define YG_RUN_DEBUG            0
#define YG_RUN_RELEASE          1

#if defined(_DEBUG)

	#define YG_RUN              YG_RUN_DEBUG

#elif defined(NDEBUG)

	#define YG_RUN              YG_RUN_RELEASE

#endif

// =========================================
// Compiler settings
// =========================================

#if (YG_COMPILER_TYPE == YG_COMPILER_TYPE_MSVC)

	// =========================================
	// Unsigned
	// =========================================

	typedef __int64                        uint64;
	typedef unsigned long                  uint32;
	typedef unsigned short                 uint16;
	typedef unsigned char                  uint8;

	// =========================================
	// Signed
	// =========================================

	typedef unsigned __int64               int64;
	typedef long                           int32;
	typedef short                          int16;
	typedef char                           int8;

	// =========================================
	// Real
	// =========================================

	typedef double                         real64;
	typedef float                          real32;
	typedef real32                         real;

#elif (YG_COMPILER_TYPE == YG_COMPILER_TYPE_GPP)

	// =========================================
	// Unsigned
	// =========================================

	typedef long long                      uint64;
	typedef unsigned long                  uint32;
	typedef unsigned short                 uint16;
	typedef unsigned char                  uint8;

	// =========================================
	// Signed
	// =========================================

	typedef unsigned long long             int64;
	typedef long                           int32;
	typedef short                          int16;
	typedef char                           int8;

	// =========================================
	// Real
	// =========================================

	typedef double                         real64;
	typedef float                          real32;
	typedef real32                         real;

#endif

// =========================================
// Files
// =========================================

#define YG_FILE_READ                       0x0001
#define YG_FILE_WRITE                      0x0002
#define YG_FILE_CLEAR                      0x0004
#define YG_FILE_BINARY                     0x0008

#define YG_SEEK_START                      0
#define YG_SEEK_CURR                       1
#define YG_SEEK_END                        2

// =========================================
// Color
// =========================================

#define YG_ALPHA_KEYING
#define YG_ALPHA_BLENDING

// types

#define YG_COLOR_DEPTH_A8R8G8B8            0
#define YG_COLOR_DEPTH_A8B8G8R8            1
#define YG_COLOR_DEPTH_R8G8B8              2
#define YG_COLOR_DEPTH_R5G6B5              3

// 16-bit colors

typedef uint16                             color16;
typedef uint16                             YG_COLOR_TYPE_R5G6B5;

#define YG_COLOR_TYPE_R5G6B5_SHIFT         4
#define YG_COLOR_TYPE_R5G6B5_SHIFT_A       0
#define YG_COLOR_TYPE_R5G6B5_SHIFT_R       8
#define YG_COLOR_TYPE_R5G6B5_SHIFT_G       4
#define YG_COLOR_TYPE_R5G6B5_SHIFT_B       0 

#define YG_COLOR_TYPE_R5G6B5_BITMASK_A    0x00
#define YG_COLOR_TYPE_R5G6B5_BITMASK_R    0xF8
#define YG_COLOR_TYPE_R5G6B5_BITMASK_G    0x7E
#define YG_COLOR_TYPE_R5G6B5_BITMASK_B    0x1F

#define YG_COLOR_TYPE_R5G6B5_MASK_A       0x0000
#define YG_COLOR_TYPE_R5G6B5_MASK_C       0xFFFF
#define YG_COLOR_TYPE_R5G6B5_MASK_R       0xF800
#define YG_COLOR_TYPE_R5G6B5_MASK_G       0x07E0
#define YG_COLOR_TYPE_R5G6B5_MASK_B       0x001F
#define YG_COLOR_TYPE_R5G6B5_MASK_RB      0xF81F
#define YG_COLOR_TYPE_R5G6B5_MASK_AG      0x07E0

// 32-bit colors

typedef uint32                            color32;
typedef uint32                            YG_COLOR_TYPE_A8R8G8B8;

#define YG_COLOR_TYPE_A8R8G8B8_SHIFT      8
#define YG_COLOR_TYPE_A8R8G8B8_SHIFT_A    24
#define YG_COLOR_TYPE_A8R8G8B8_SHIFT_R    16
#define YG_COLOR_TYPE_A8R8G8B8_SHIFT_G    8
#define YG_COLOR_TYPE_A8R8G8B8_SHIFT_B    0

#define YG_COLOR_TYPE_A8R8G8B8_BITMASK_A  0xFF
#define YG_COLOR_TYPE_A8R8G8B8_BITMASK_R  0xFF
#define YG_COLOR_TYPE_A8R8G8B8_BITMASK_G  0xFF
#define YG_COLOR_TYPE_A8R8G8B8_BITMASK_B  0xFF

#define YG_COLOR_TYPE_A8R8G8B8_MASK_A     0xFF000000
#define YG_COLOR_TYPE_A8R8G8B8_MASK_C     0x00FFFFFF
#define YG_COLOR_TYPE_A8R8G8B8_MASK_R     0x00FF0000
#define YG_COLOR_TYPE_A8R8G8B8_MASK_G     0x0000FF00
#define YG_COLOR_TYPE_A8R8G8B8_MASK_B     0x000000FF
#define YG_COLOR_TYPE_A8R8G8B8_MASK_RB    0x00FF00FF
#define YG_COLOR_TYPE_A8R8G8B8_MASK_AG    0xFF00FF00

typedef uint32                            YG_COLOR_TYPE_A8B8G8R8;

#define YG_COLOR_TYPE_A8B8G8R8_SHIFT      8
#define YG_COLOR_TYPE_A8B8G8R8_SHIFT_A    24
#define YG_COLOR_TYPE_A8B8G8R8_SHIFT_R    0
#define YG_COLOR_TYPE_A8B8G8R8_SHIFT_G    8
#define YG_COLOR_TYPE_A8B8G8R8_SHIFT_B    16

#define YG_COLOR_TYPE_A8B8G8R8_BITMASK_A  0xFF
#define YG_COLOR_TYPE_A8B8G8R8_BITMASK_R  0xFF
#define YG_COLOR_TYPE_A8B8G8R8_BITMASK_G  0xFF
#define YG_COLOR_TYPE_A8B8G8R8_BITMASK_B  0xFF

#define YG_COLOR_TYPE_A8B8G8R8_MASK_A     0xFF000000
#define YG_COLOR_TYPE_A8B8G8R8_MASK_C     0x00FFFFFF
#define YG_COLOR_TYPE_A8B8G8R8_MASK_R     0x000000FF
#define YG_COLOR_TYPE_A8B8G8R8_MASK_G     0x0000FF00
#define YG_COLOR_TYPE_A8B8G8R8_MASK_B     0x00FF0000
#define YG_COLOR_TYPE_A8B8G8R8_MASK_RB    0x00FF00FF
#define YG_COLOR_TYPE_A8B8G8R8_MASK_AG    0xFF00FF00

typedef uint32                            YG_COLOR_TYPE_R8G8B8;

#define YG_COLOR_TYPE_R8G8B8_SHIFT        8
#define YG_COLOR_TYPE_R8G8B8_SHIFT_A      24
#define YG_COLOR_TYPE_R8G8B8_SHIFT_R      16
#define YG_COLOR_TYPE_R8G8B8_SHIFT_G      8
#define YG_COLOR_TYPE_R8G8B8_SHIFT_B      0

#define YG_COLOR_TYPE_R8G8B8_BITMASK_A    0x00
#define YG_COLOR_TYPE_R8G8B8_BITMASK_R    0xFF
#define YG_COLOR_TYPE_R8G8B8_BITMASK_G    0xFF
#define YG_COLOR_TYPE_R8G8B8_BITMASK_B    0xFF

#define YG_COLOR_TYPE_R8G8B8_MASK_A       0x00000000
#define YG_COLOR_TYPE_R8G8B8_MASK_C       0x00FFFFFF
#define YG_COLOR_TYPE_R8G8B8_MASK_R       0x00FF0000
#define YG_COLOR_TYPE_R8G8B8_MASK_G       0x0000FF00
#define YG_COLOR_TYPE_R8G8B8_MASK_B       0x000000FF
#define YG_COLOR_TYPE_R8G8B8_MASK_RB      0x00FF00FF
#define YG_COLOR_TYPE_R8G8B8_MASK_AG      0x0000FF00

#if (YG_OS_TYPE == YG_OS_TYPE_WINDOWSMOBILE)

	#define YG_COLOR_DEPTH                YG_COLOR_DEPTH_R5G6B5

#elif (YG_OS_TYPE == YG_OS_TYPE_ANDROID)

	#define YG_COLOR_DEPTH                YG_COLOR_DEPTH_A8B8G8R8

#endif

// =========================================
// Sprite
// =========================================

#define YG_SPRITE_QUALITY_LOW              0x00000001
#define YG_SPRITE_QUALITY_MEDIUM           0x00000002
#define YG_SPRITE_QUALITY_HIGH             0x00000004
#define YG_SPRITE_TRANSPARANCY_KEYING      0x00000008
#define YG_SPRITE_TRANSPARANCY_BLENDING    0x00000010

// =========================================
// SpriteEx
// =========================================

#define YG_SPRITEEX_ANIMATION              0x00000001
#define YG_SPRITEEX_NOANIMATION            0x00000002
#define YG_SPRITEEX_ROTATION               0x00000004
#define YG_SPRITEEX_NOROTATION             0x00000008
#define YG_SPRITEEX_SCALING                0x00000010
#define YG_SPRITEEX_NOSCALING              0x00000020
#define YG_SPRITEEX_TRANSPARANCY_KEYING    0x00000040
#define YG_SPRITEEX_TRANSPARANCY_BLENDING  0x00000080

#define YG_SPRITEEX_DEFAULT                (YG_SPRITEEX_ANIMATION | YG_SPRITEEX_ROTATION | YG_SPRITEEX_SCALING)

// =========================================
// Background
// =========================================

#define YG_BACKGROUND_DEFAULT              0x00000000

// =========================================
// Surfaces
// =========================================

#define YG_SURFACE_NOTHING                 0x00000001
#define YG_SURFACE_CLIPPER                 0x00000002

#define YG_SURFACE_DEFAULT                 (YG_SURFACE_NOTHING)

// =========================================
// Viewport
// =========================================

#define YG_VIEWPORT_NOTHING                0x000000001
#define YG_VIEWPORT_SCALEX                 0x000000002
#define YG_VIEWPORT_SCALEY                 0x000000004
#define YG_VIEWPORT_SCALEXY                0x000000008
#define YG_VIEWPORT_VIEWPORT               0x000000010
#define YG_VIEWPORT_CENTER                 0x000000020
#define YG_VIEWPORT_TOPLEFT                0x000000040
#define YG_VIEWPORT_TOPRIGHT               0x000000080
#define YG_VIEWPORT_BOTTOMLEFT             0x000000100
#define YG_VIEWPORT_BOTTOMRIGHT            0x000000200

#define YG_VIEWPORT_DEFAULT                (YG_VIEWPORT_NOTHING)

#if (YG_OS_TYPE == YG_OS_TYPE_WINDOWSMOBILE)

	#define YG_STUB						     __pragma(comment(user, "'" __FUNCTION__ "' is not yet implemented."))

#elif (YG_OS_TYPE == YG_OS_TYPE_ANDROID)

	#define YG_STUB_DO_PRAGMA(x)             _Pragma (#x)
	#define YG_STUB_DO_MSG2(x)               YG_STUB_DO_PRAGMA(message (#x))
	#define YG_STUB_DO_MSG(x)                YG_STUB_DO_MSG2(x)
	#define YG_STUB                          YG_STUB_DO_MSG(Function not yet implemented.)

#endif


// TODO: Fill it with stuff

struct GlobalSettings
{
	
};

#endif
